var VDCList = new Pearlsen.BaseList(
		{
			gridId : 'VDCGrid',
			advSearchId : 'advSearchWin',
			module : '虚拟数据中心维护',
			modulePath : '/pages/rms/VDCMgr/',
			moduleName : 'VDCMgr',
			idProperty : 'VDC_ID',
			nameProperty : 'VDC_NAME',
			dataSetHandler : 'VDCMgrDatasetHandler',
			queryHandler : 'VDCMgrQueryHandler',

			statusRender : function(value) {
				var val = "";
				switch (value) {
				case "1":
					val = "<span style='color:green;'>正常</span>";
					break;
				case "0":
					val = "<span style='color:red;'>不正常</span>";
					break;
				}
				return val;
			},

			isEnableRender : function(value) {
				var val = "";
				switch (value) {
				case true:
					val = "<span style='color:green;'>已启用</span>";
					break;
				case false:
					val = "<span style='color:red;'>禁用</span>";
					break;
				}
				return val;
			},

			cpuRender : function(value, meta, record) {

				return value + record.get("VDC_CpuUnits");
			},

			memoryRender : function(value, meta, record) {
				return value + record.get("VDC_MemoryUnits");
			},

			hardDiskRender : function(value, meta, record) {
				return value + record.get("VDC_HardDiskUnits");
			},

			setEnabled : function() {
				var me = VDCList;
				var grid = me.getGrid();
				var record = grid.getSelectionModel().getLastSelected();
				if(!record){
					Pearlsen.Utils.showInfoMsg("请选择一条记录");	
					return;
				}
				var ds = new DataSet('VDCMgrDatasetHandler',
						'VDCMgrDatasetHandler');
				ds.setHandlerMethod("setEnabled");
				ds.addCondition("VDC_Name", record.get('VDC_Name'));
				ds.execute(me.rebootVMCallBack);
			},

			setEnabledCallBack : function(result) {
				if (result.success) {
					Pearlsen.Utils.showInfoMsg("启用成功!");
				} else {
					Pearlsen.Utils.showErrorMsg("出错了,原因:" + result.message);
				}
			},

			setDisabled : function() {
				var me = VDCList;
				var grid = me.getGrid();
				var record = grid.getSelectionModel().getLastSelected();
				if(!record){
					Pearlsen.Utils.showInfoMsg("请选择一条记录");	
					return;
				}
				var ds = new DataSet('VDCMgrDatasetHandler',
						'VDCMgrDatasetHandler');
				ds.setHandlerMethod("setDisabled");
				ds.addCondition("VDC_Name", record.get('VDC_Name'));
				ds.execute(me.rebootVMCallBack);
			},

			setDisabledCallBack : function(result) {
				if (result.success) {
					Pearlsen.Utils.showInfoMsg("禁用成功!");
				} else {
					Pearlsen.Utils.showErrorMsg("出错了,原因:" + result.message);
				}
			},

			goToVapp : function() {
				var me = VDCList;
				var grid = me.getGrid();
				var record = grid.getSelectionModel().getLastSelected();
				if(!record){
					Pearlsen.Utils.showInfoMsg("请选择一条记录");	
					return;
				}
				var tabId = VDCList.createTabId(record.get('VDC_Name'));
				parent.MainTab.addTab(tabId, "项目维护",
						"/pages/rms/vappmgr/vapp.jsp?VDC_Name="
								+ record.get('VDC_Name'));
			},

			loadChart : function() {
				var me = VDCList;
				var grid = me.getGrid();
				var record = grid.getSelectionModel().getLastSelected();
				
				var unusedCpu = 0;
				var unusedMemory = 0;
				var unusedHardDisk = 0;
				// cpu
			if (record.get("VDC_CpuOverhead") == 0)
				var unusedCpu = record.get("VDC_CpuAssign")
						- record.get("VDC_CpuUsed");
			// memory
			if (record.get("VDC_MemoryOverhead") == 0)
				var unusedMemory = record.get("VDC_MemoryAssign")
						- record.get("VDC_MemoryUsed");
			// harddisk
			if (record.get("VDC_HardDiskOverHead") == 0)
				var unusedHardDisk = record.get("VDC_HardDiskAssign")
						- record.get("VDC_HardDiskUsed");

			Ext.getCmp('chart').store.loadData( [
					{
						kind : "cpu",
						'使用率' : VDCList.returnFloat(record.get("VDC_CpuUsed"),
								record.get("VDC_CpuAssign")),
						'未使用率' : VDCList.returnFloat(unusedCpu, record
								.get("VDC_CpuAssign")),
						'超出率' : VDCList.returnFloat(record
								.get("VDC_CpuOverhead"), record
								.get("VDC_CpuAssign")),
						total : record.get("VDC_CpuAssign")
					},
					{
						kind : "内存",
						'使用率' : VDCList.returnFloat(record
								.get("VDC_MemoryUsed"), record
								.get("VDC_MemoryAssign")),
						'未使用率' : VDCList.returnFloat(unusedMemory, record
								.get("VDC_MemoryAssign")),
						'超出率' : VDCList.returnFloat(record
								.get("VDC_MemoryOverhead"), record
								.get("VDC_MemoryAssign")),
						total : record.get("VDC_MemoryAssign")
					},
					{
						kind : "硬盘",
						'使用率' : VDCList.returnFloat(record
								.get("VDC_HardDiskUsed"), record
								.get("VDC_HardDiskAssign")),
						'未使用率' : VDCList.returnFloat(unusedHardDisk, record
								.get("VDC_HardDiskAssign")),
						'超出率' : VDCList.returnFloat(record
								.get("VDC_HardDiskOverHead"), record
								.get("VDC_HardDiskAssign")),
						total : record.get("VDC_HardDiskAssign")
					} ]);
		},
		// 乘以100倍后， 保留两位小数点
			returnFloat : function(a, b) {
				if (b == 0)
					return 0;
				var value = a / b;
				value = Math.round(parseFloat(value) * 100) / 100;
				if (value.toString().indexOf(".") < 0) {
					value = value.toString() + ".00";
				}
				return value * 100;
			}
		});
